package com.kehutong.common.constant;

import java.util.regex.Pattern;

/**
 * 正则表达式常量
 * @author jian Ye
 **/
public class RegexConstant {


    public final static Pattern MOBILE_REGEX = Pattern.compile(RegexConstant.MOBILE_FORMAT);
    public final static Pattern MONEY_REGEX = Pattern.compile(RegexConstant.MONEY_FORMAT);
    public final static Pattern YEAR_MONTH_REGEX = Pattern.compile(RegexConstant.YEAR_MONTH_FORMAT);
    public final static Pattern YEAR_MONTH_DAY_REGEX = Pattern.compile(RegexConstant.YEAR_MONTH_DAY_FORMAT);
    public final static Pattern NUMBER_REGEX = Pattern.compile(RegexConstant.NUMBER_FORMAT);
    public final static Pattern CHINESE_REGEX = Pattern.compile(RegexConstant.CHINESE_NAME_FORMAT);




    /***只能是数字格式*/
    public static final String NUMBER_FORMAT = "^[0-9]+$";

    /***只能是金额格式*/
    public static final String MONEY_FORMAT = "^-?(?:0|[1-9]\\d*)(?:\\.\\d*[0-9])?$";

    /***时间格式格式 2021-08 */
    public static final String YEAR_MONTH_FORMAT = "^[1-9]\\d{3}-(0[1-9]|1[0-2])$";

    /***时间格式格式 2021-08-11 */
    public static final String YEAR_MONTH_DAY_FORMAT = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$";

    /***时间格式格式 2021-08-11 12:00:00 */
    public static final String YEAR_MONTH_DAY_TIME_FORMAT = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])" +
            "\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$";

    /***只能是英文或数字格式*/
    public static final String ENGLISH_NUMBER_FORMAT = "^[A-Za-z0-9]+$";

    /***中文姓名格式*/
    public static final String CHINESE_NAME_FORMAT = "^$|^[\\u4e00-\\u9fa5.·\\u36c3\\u4DAE]{2,30}$";

    /***匹配中文、英文、数字、下划线*/
    public static final String ENGLISH_CHINESE_16FORMAT = "^[\\u4e00-\\u9fa5_a-zA-Z]{1,16}+$";

    /***手机号码格式*/
    public static final String MOBILE_FORMAT = "^$|^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))" +
            "|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";

    /***15-18位最后一位可为字母身份证格式*/
    public static final String ID_CARD_NO_FORMAT = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])" +
            "|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)";

    /***银行卡格式*/
    public static final String BANK_CARD_NO_FORMAT = "^([1-9]{1})(\\d{15}|\\d{16}|\\d{17}|\\d{18})$";

    /***HTTP正则 */
    public static final String HTTP_FORMAT = "((http|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+(" +
            "[\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?)";

    /***中英文数字和符号_,.!*/
    public static final String TITLE_NO="^[_,.!\\n\\w\\u4e00-\\u9fa5]*$";

}